package com.freewater.parking.adapter;

import com.freewater.parking.application.BlackListAppService;
import com.freewater.parking.domain.common.PlateNumber;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/blackList")
public class BlackListController {

    private BlackListAppService blackListAppService;

    @PostMapping("/addPlateNumber")
    public void addPlateNumber(@Validated @RequestBody AddToBlackListRequest request) {
        PlateNumber plateNumber = new PlateNumber(request.getPlateNumber());
        this.blackListAppService.addPlateNumber(plateNumber);
    }

    @PostMapping("/removePlateNumber")
    public void removePlateNumber(@Validated @RequestBody RemoveFromBlackListRequest request) {
        PlateNumber plateNumber = new PlateNumber(request.getPlateNumber());
        this.blackListAppService.removePlateNumber(plateNumber);
    }


    @GetMapping("/existPlateNumber")
    public boolean existPlateNumber(@RequestParam String plateNumber) {
        return this.blackListAppService.existPlateNumber(new PlateNumber(plateNumber));
    }
}
